<?php
/**
 * JoiGallery - image gallery component for Joostina
 *
 * Шаблон вывода страницы редактирования изображения
 *
 * @version 1.0 alpha 12
 * @package JoiGallery
 * @subpackage	View
 * @filename default.php
 * @author JoostinaTeam
 * @copyright (C) 2008-2009 Joostina Team
 * @license see license.txt
 *
 **/
defined('_VALID_MOS') or die();

//Подключаем CSS-файл шаблона
//$mainframe->addCSS(JPATH_SITE.'/components/com_joigallery/view/css/default.css');
?>

<?php if(!$params->_access->allow_me('edit_photo', $my->gid)){?>
         <div class="error"><?php echo $params->_access->error('edit_photo'); ?></div>
<?php return ; } ?>

<?php if(!$params->_access->allow_me('edit_own_photo', $my->gid) && $my->id == $row->user_id){?>
         <div class="error"><?php echo $params->_access->error('edit_own_photo'); ?></div>
<?php return ; } ?>

<div class="joi_gallery">
  <div class="joi_gallery_editphoto">

    <?php
    if ($params->edit_image_pathway)
         echo '<div class="joi_gallery_pathway">'.mosPathWay().'</div>';
    ?>

    <div class="componentheading">
      <div class="buttons fr">
        <span class="button">
          <a class="button apply_item" href="javascript:void(0)" ><?php echo _APPLY?></a>
        </span>
        <span class="button">
          <a class="button save_item" href="javascript:void(0)" ><?php echo _SAVE?></a>
        </span>
        <span class="button">
          <a class="button cancel cancel_item" href="javascript:void(0);" ><?php echo _CANCEL?></a>
        </span>
      </div>
      <?php if ($params->get('edit_image_pagetitle')) { ?>
                <h1><?php echo $params->get('edit_image_pagetitle'); ?></h1>
      <?php }
            else echo '<div class="clrpx">&nbsp;</div>';
      ?>
    </div>
    <div class="clrpx">&nbsp;</div>

    <img src="<?php echo JPATH_SITE.$params->thumbnail_path.'/'.$photo->path; ?>"
         alt="<?php echo $photo->name; ?>"
         border="0" 
         class="fr nodisplay"
         style="border: thin solid #ccc;padding:2px;background: #F0F0EE" />

    <form action="<?php echo sefRelToAbs('index.php')?>"
          method="post"
          id="item_form"
          class="item_form" name="item_form" enctype="multipart/form-data">

      <table class="adminlist" width="100%" cellpadding="0" cellspacing="0">
		<tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <?php if($params->get('add_image_fname', 1)){ ?>
		<tr>
          <td id="name_txt"><?php echo _C_JOIGALLERY_NAME; ?>: </td>
          <?php if($params->get('edit_image_fname', 1)){ ?>
          <td><input type="text" id="name" name="name" class="inputbox" size="30" value="<?php echo $photo->name; ?>" /></td>
          <?php }else{ ?>
          <td><?php echo $photo->name; ?></td>
          <?php } ?>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <?php } ?>
        <tr>
          <td width="150"><?php echo _C_JOIGALLERY_CATEGORY; ?>: </td>
          <?php if($params->get('edit_image_cat', 1)){ ?>
          <td><?php echo mosHTML::selectList($photo->catlist, 'cid', 'class="inputbox"', 'id', 'name', $photo->cid); ?></td>
          <?php }else{ ?>
          <td><?php echo $photo->cid; ?></td>
        <?php } ?>
        </tr>

        <?php if($params->get('add_image_pubunpub', 1)){ ?>
        <tr>
         <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td><?php echo _C_JOIGALLERY_PUBLISHED; ?>: </td>
              <?php if((   $params->_access->allow_me('set_state', $my->gid)
                        || $params->_access->allow_me('set_state_own', $my->gid))
                        && $params->get('edit_image_pubunpub', 1)) { ?>
          <td><?php echo mosHTML::yesnoRadioList('state', '', $photo->state); ?></td>
          <?php }else{ ?>
          <td><?php echo $photo->state; ?></td>
          <?php } ?>
        </tr>
        <?php } ?>

        <?php if((   $params->_access->allow_me('main_photo', $my->gid)
                  || $params->_access->allow_me('main_photo_own', $my->gid))
                  && $params->get('edit_image_default', 1)): ?>
        <tr>
          <td><?php echo _C_JOIGALLERY_PHOTO_GALLERY_THUMBNAIL; ?>: </td>
          <td><?php echo mosHTML::yesnoRadioList('default', '', $photo->default); ?></td>
        </tr>
        <?php endif; ?>        
        <?php if($params->get('add_image_fdesc', 1)){ ?>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td>
           <?php echo _C_JOIGALLERY_DESCRIPTION; ?>:
          </td>
          <td>
            <?php if($params->get('edit_image_fdesc', 1)){  ?>
            <?php if($params->get('edit_image_fdesc_wwyg', 1)){ ?>
              <?php editorArea( 'editor1',  $photo->description , 'description', '100%;', '300', '60', '20', $wwig_params ) ; ?>
            <?php }else{ ?>
              <textarea rows="10" cols="100" class="inputbox text_area" name="description"><?php echo $photo->description ?></textarea>
            <?php } ?>
            <?php } else{ ?>
            <?php echo $photo->description; ?>
            <?php }?>

            <?php }?> 
          </td>
        </tr>
		<tr>
          <td colspan="2">&nbsp;</td>
        </tr>        
        <tr>
          <td>&nbsp;</td>
          <td>
            <div class="buttons">
              <span class="button">
                <a class="button apply_item" href="javascript:void(0)" ><?php echo _APPLY?></a>
              </span>
              <span class="button">
                <a class="button save_item" href="javascript:void(0)" ><?php echo _SAVE?></a>
              </span>
              <span class="button">
                <a class="button cancel cancel_item" href="javascript:void(0);" ><?php echo _CANCEL?></a>
              </span>
            </div>
          </td>
        </tr>
		<tr>
          <td colspan="2">&nbsp;</td>
        </tr>
      </table>     

      <?php if($params->get('extrafields_add_photo', 0)){
                $extra_fields->load_fileds_with_values('1', $photo->id);
                $extra_fields->print_all_fields('editPhoto', $params->get('extrafields_auto_js', 1));
      }?>

      <?php //Тэги
      if(defined('JOITAGS')){      
          $tags = new joiTags($mainframe, 'com_joigallery');
          $tags->display_object_tags_edit($photo);
      }
      ?>     

      <input type="hidden" name="Itemid" value="<?php echo $params->_Itemid; ?>" />
      <input type="hidden" name="id" value="<?php echo $photo->id; ?>" />
      <input type="hidden" name="option" value="<?php echo $params->_option; ?>" />
      <input type="hidden" name="task" id="task" value="" />
      <input type="hidden" name="act" value="photos" />
      
    </form>

  </div>
</div>

<script language="javascript" type="text/javascript">
  //Проверка формы 
    $('#item_form').submit(function() {
        if (!$('#name').val()) {			
			alert("<?php echo _C_JOIGALLERY_MSG_SAVE_ERR_IMG_NAME_EMPTY; ?>");
			$('#name_txt').css("color", "red");
			return false;
		}
    });
</script>